//
//  DBNavigationView.m
//  MyBarcodeStore
//
//  Created by mac on 2010/7/26.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "DBNavigationViewController.h"

@implementation DBNavigationViewController

@synthesize viewDBPage;
@synthesize pageDetail;

- (id)init {
	if ((self = [super init]) != nil)
	{
		self.tabBarItem.image =
		[UIImage imageWithString:@"\u25C9" // Unicode code for a check-mark.
							font:[UIFont systemFontOfSize:
								  [UIFont systemFontSize]]
							size:CGSizeMake(29, 29)];
		
		viewDBPage = [[ViewDBPage alloc] init];
		viewDBPage.tableView.delegate = self;
		
		pageDetail = [[ViewDBPageDetail alloc] initWithStyle:UITableViewStyleGrouped];
		
		[self pushViewController:viewDBPage animated:YES];
	}
	
	return self;
}

- (void)dealloc {
	[viewDBPage release];
	[super dealloc];
}

// About TabelViewControllerDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
	UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
	/*
#ifdef DEBUG
	NSLog(@"Create a new mail to send with attached files.");
#endif
	MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
	picker.mailComposeDelegate = self;
	
	[picker setToRecipients:[[NSArray alloc] initWithObjects:@"kuanling.haung@gmail.com", nil]];
	[picker setSubject:@"Message from MyStore"];
	[picker setMessageBody:cell.textLabel.text isHTML:NO];
	
	//[self presentModalViewController:picker animated:YES];
	 */
	pageDetail.result = [viewDBPage resultAtIndex:indexPath.row];
	[self pushViewController:pageDetail animated:YES];
	//[picker release];
}

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
#ifdef DEBUG
	NSLog(@"MailComposer did finished.");
#endif
	[self dismissModalViewControllerAnimated:YES];
}

@end
